﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Web;

namespace CNVP.Config
{
    /// <summary>
    /// URL地址配置读取类
    /// </summary>
    public class UrlFormat
    {
        /// <summary>
        /// 全局XML文档对象
        /// </summary>
        private static XmlDocument xml = new XmlDocument();
        /// <summary>
        /// 全局完整后缀配置文件保存的服务器路径
        /// </summary>
        private static String xmlPath = HttpContext.Current.Server.MapPath("~/Config/UrlFormat.config");
        /// <summary>
        /// 读取指定项目下的值
        /// </summary>
        /// <param name="itemName">项目名</param>
        /// <returns>值</returns>
        public static String GetSingle(String itemName)
        {
            xml.Load(xmlPath);
            XmlNodeList rootList = xml.SelectNodes(string.Format("UrlFormat/{0}", itemName));
            String g = String.Empty;
            if (rootList.Count > 0)
            {
                XmlNode xn = rootList[0];
                g = Convert.ToString(xn.InnerText);
                return g;
            }
            else
            {
                return String.Empty;
            }
        }
        /// <summary>
        /// 列表地址规则
        /// </summary>
        public static String f_List =UIConfig.InstallDir+GetSingle("List");
        /// <summary>
        /// 带分页列表地址规则
        /// </summary>
        public static String f_ListPage = UIConfig.InstallDir + GetSingle("ListPage");
        /// <summary>
        /// 带栏目ID内页地址规则
        /// </summary>
        public static String f_DetailWithColumn = UIConfig.InstallDir + GetSingle("DetailWithColumn");
        /// <summary>
        /// 内页地址规则
        /// </summary>
        public static String f_Detail = UIConfig.InstallDir + GetSingle("Detail");
        /// <summary>
        /// 带栏目ID文章内页地址规则
        /// </summary>
        public static String f_NewsDetailWithColumn = UIConfig.InstallDir + GetSingle("NewsDetailWithColumn");
        /// <summary>
        /// 文章内页地址规则
        /// </summary>
        public static String f_NewsDetail = UIConfig.InstallDir + GetSingle("NewsDetail");
    }
}
